﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SpriteLoader : MonoBehaviour
{
    public string sprite_path;
    
	void Awake()
	{
		Renderer renderer = GetComponent<Renderer>();
		if(renderer != null && renderer is SpriteRenderer)
		{
			SpriteRenderer render = renderer as SpriteRenderer;
			if(render.sprite == null)
			{
				render.SetSprite(sprite_path);
			}
		}
		else
		{
			Image image = this.gameObject.GetComponent<Image>();
			if(image != null && image.sprite == null)
			{
				image.SetSprite(sprite_path);
			}
		}
	}
}
